<template>
  <div class="list">
    <el-table
      :data="roleListData"
      style="width: 100%; margin-bottom: 20px"
      row-key="id"
      border
      height="510"
    >
      <el-table-column prop="id" label="编号" sortable width="180">
      </el-table-column>
      <el-table-column prop="rolename" label="名称" sortable width="500">
      </el-table-column>
      <el-table-column prop="status" label="状态">
        <template slot-scope="scope">
          <el-tag v-if="scope.row.status == 1">启用</el-tag>
          <el-tag v-if="scope.row.status == 2" type="danger">禁用</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button type="primary" @click="editRole(scope.row.id)">编辑</el-button>
          <el-button type="danger" @click="deleteRole(scope.row.id)"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { getRoleDelete } from "../../../request/api";
export default {
  props: ["roleListData"],
  data() {
    return {};
  },
  mounted() {},
  methods: {
    // 编辑角色
    editRole(id){
      this.$emit('editRole',id)
    },
    //  删除角色
    deleteRole(id) {
      this.$confirm("是否删除该菜单?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
      }).then(() => {
        getRoleDelete({ id }).then(
          (res) => {
            if (res.data.code == 200) {
              this.$message.success("删除成功");
              // 刷新列表数据
              this.$emit("refreshForm");
            }
          },
          (err) => err
        );
      },err=>err);
    },
  },
};
</script>

<style scoped>
</style>